<?
/**
 * 后台管理低层
 * 
 * @copyright Copyright (c) 2008 sdmblog (http://www.sdmblog.cn)
 * @author sdomain(sdomain@live.cn)
 * @version admin.model.php Sun Jun 01 22:09:18 CST 2008 php $
 */
class model_admin {
	/**
	 * 后台登录
	 *
	 * @param int $uid 用户ID-根据事先登录的COOKIE信息得到的
	 * @param string $passwd 登录密码
	 * @return unknown
	 */
	function loginadmin($uid,$passwd) {
		global $db,$tablepre,$webstate;
		$md5passwd = md5($passwd);
		if ($webstate==1) {
			$sql = 'select `password` from `'.$tablepre.'users` where `id`=\''.$uid.'\' and `password`=\''.$md5passwd.'\' and `groupid`=1';
		}else {
			$sql = 'select `password` from `'.$tablepre.'users` where `username`=\''.$uid.'\' and `password`=\''.$md5passwd.'\' and `groupid`=1';
		}
		try {
			$db->query($sql);
		}catch (Exception $e){
			return $e->getMessage();
		}
		if ($db->numRows!=1) {
			return 0;
		}else {
			return 1;
		}
	}
	/**
	 * 取得服务器相关信息
	 *
	 * @return 服务器信息的数组
	 */
	function getServerInfo()
	{
		global $db;
		$sql = 'select version() as version';
		$res = $db->query($sql);
		$arrinfo = $db->db_fetch_array();
		$serverInfo['mysqlver'] = $arrinfo['version'];
		$serverInfo['ip'] = $_SERVER['SERVER_ADDR'];
		$serverInfo['path'] = substr($_SERVER['SCRIPT_FILENAME'],0,-21);
		$serverInfo['element'] = $_SERVER['SERVER_SOFTWARE'];
		return $serverInfo;
	}
	/**
	 * 生成显示服务器信息的HTML代码
	 *
	 * @param array $serverInfo 保存服务器信息的数组
	 * @return HTML代码
	 */
	
	function indexHtml($serverInfo)
	{
		global $webstate;
		$strwebstate = $webstate==1?'<a href="javascript:void(null)" onclick="closeSite();">关闭站点</a>':'<a href="javascript:void(null)" onclick="openSite();">打开站点</a>';
		$strHTML = '<div class="textbox-title"><h4>基本信息</h4></div>
					<div class="textbox-content">
						<table border="0" cellpadding="0" cellspacing="1">
					    <tr>
							<td class="formbox-rowheader">sdmblog版本:</td>
							<td class="formbox-content">
							2.0.313 
							|
							'.$strwebstate.'
							|
					        <a href="?cleancache=doit">清除缓存</a>
							</td>
						</tr>
						<tr>
							<td class="formbox-rowheader">
							服务器IP:
							</td>
							<td class="formbox-content">
							'.$serverInfo['ip'].'
							</td>
						</tr>
						<tr>
							<td class="formbox-rowheader">
							站点路径:
							</td>
							<td class="formbox-content">
							'.$serverInfo['path'].'
							</td>
						</tr>
						<tr>
							<td class="formbox-rowheader">
							服务器环境版本:
							</td>
							<td class="formbox-content">
							'.$serverInfo['element'].'
							</td>
						</tr>
						<tr>
							<td class="formbox-rowheader">
							MYSQL版本:
							</td>
							<td class="formbox-content">
							'.$serverInfo['mysqlver'].'
							</td>
						</tr>
						</table>
				      </div>';
		return $strHTML;
	}
	/**
	 * 读取基本设置信息,并生成基本设置页面
	 *
	 * @return 基本设置页HTML代码
	 */
	function loadSettings()
	{
		global $virdir;
		//Blog 主题
		$settings['blogtitle'] = GP('blogtitle');
		//Blog 描述
		$settings['blogmemo'] = GP('blogmemo');
		//Blog 链接
		$settings['blogurl'] = GP('blogurl');
		//Blog Logo 图片
		$settings['bloglogo'] = GP('bloglogo');
		//站长名称:
		$settings['blogwebmaster'] = GP('blogwebmaster');
		//站长Email
		$settings['masteremail'] = GP('masteremail');
		//网站友情连接
		$settings['links'] = GP('links');
		//语言
		$settings['bloglanguage'] = GP('bloglanguage');
		//默认显示模式
		$settings['viewmodel'] = GP('viewmodel');
		//每页日志数 普通/列表
		$settings['normalperpage'] = GP('normalperpage');
		$settings['listperpage'] = GP('listperpage');
		//每页评论数
		$settings['percomment'] = GP('percomment');
		//评论排序
		$settings['commentorder'] = GP('commentorder');
		//最新日志
		$settings['newblognum'] = GP('newblognum');
		//最新评论
		$settings['newcomment'] = GP('newcomment');
		//首页日志显示长度，超长自动截断
		$settings['indexbloglen'] = GP('indexbloglen');
		//开放注册
		$settings['enableregister'] = GP('enableregister');
		//使用校验码
		$settings['enablesecuritycode'] = GP('enablesecuritycode');
		//开放评论
		$settings['enablecomment'] = GP('enablecomment');
		//评论最大长度
		$settings['commentlen'] = GP('commentlen');
		//开放留言
		$settings['enableguestbook'] = GP('enableguestbook');
		//每页留言数
		$settings['guestbookperpage'] = GP('guestbookperpage');
		//网站样式选择
		$settings['style'] = GP('style');
		//防灌机制
		$settings['minposttime'] = GP('minposttime');
		//允许上传
		$settings['enableupload'] = GP('enableupload');
		//上传文件大小限制
		$settings['uploadsize'] = GP('uploadsize');
		//上传文件路径
		$settings['uploadpath'] = GP('uploadpath');
		//上传文件类型
		$settings['uploadtypes'] = GP('uploadtypes');
		
		$strviewmodel = $settings['viewmodel']=='list'?'<input type="radio" name="viewmodel" value="normal" />普通&nbsp;&nbsp; <input type="radio" name="viewmodel" value="list" checked="checked"/>列表':'<input type="radio" name="viewmodel" value="normal" checked="checked" />普通&nbsp;&nbsp; <input type="radio" name="viewmodel" value="list"/>列表';
		$strcommentorder = $settings['commentorder']=='desc'?'<input type="radio" name="commentorder" value="asc" />发表时间升序排列&nbsp;&nbsp; <input type="radio" name="commentorder" value="desc" checked="checked" />发表时间降序排列':'<input type="radio" name="commentorder" value="asc" checked="checked" />发表时间升序排列&nbsp;&nbsp; <input type="radio" name="commentorder" value="desc" />发表时间降序排列';
		$strenablereg = $settings['enableregister']=='1'?'<input type="checkbox" name="enableregister" value="1" checked="checked" /> 可用':'<input type="checkbox" name="enableregister" value="1"/> 可用';
		$strsecuritycode = $settings['enablesecuritycode']=='1'?'<input type="checkbox" name="enablesecuritycode" value="1" checked="checked" /> 可用':'<input type="checkbox" name="enablesecuritycode" value="1" /> 可用';
		$strenablecomment = $settings['enablecomment']=='1'?'<input type="checkbox" name="enablecomment" value="1" checked="checked" /> 可用':'<input type="checkbox" name="enablecomment" value="1"/> 可用';
		$strenablegb = $settings['enableguestbook']=='1'?'<input type="checkbox" name="enableguestbook" value="1" checked="checked" /> 可用':'<input type="checkbox" name="enableguestbook" value="1" /> 可用';
		$styledirs = listDir(ROOT_PATH.'styles/');
		foreach ($styledirs as $styledir){
			if (file_exists(ROOT_PATH.'styles/'.$styledir.'/styles.css')) {
				if ($settings['style']==$styledir) {
					$stroption .='<option value="'.$styledir.'" selected>'.$styledir.'</option>';
				}else {
					$stroption .='<option value="'.$styledir.'">'.$styledir.'</option>';
				}
			}
		}
		$strupload = $settings['enableupload']=='1'?'<input type="checkbox" name="enableupload" value="1" checked="checked"/> 可用':'<input type="checkbox" name="enableupload" value="1" /> 可用';
		$strHTML = '
					<div class="textbox-title"><h4>基本设置</h4></div>
					<div class="textbox-content">
					<table border="0" cellpadding="2" cellspacing="1">
					<form method="post" action="javascript:void(null);" id="basicsetting" onsubmit="return saveSettings();">
					<tr>
					  <td class="formbox-rowheader" width="140">Blog 主题:</td>
					  <td class="formbox-content"><input type="text" name="blogtitle" size="60" value="'.$settings['blogtitle'].'" maxlength="250" class="text" /></td>
					</tr>
					<tr>
					  <td class="formbox-rowheader">Blog 描述:</td>
					  <td class="formbox-content"><input type="text" name="blogmemo" size="60" value="'.$settings['blogmemo'].'" maxlength="250" class="text" /></td>
					</tr>
					<tr>
					  <td class="formbox-rowheader">Blog 链接:</td>
					  <td class="formbox-content"><input type="text" name="blogurl" size="60" value="'.$settings['blogurl'].'" maxlength="250" class="text" /></td>
					</tr>
					<tr>
					  <td class="formbox-rowheader">Blog Logo 图片:</td>
					  <td class="formbox-content"><input type="text" name="bloglogo" size="60" value="'.$settings['bloglogo'].'" maxlength="250" class="text" /></td>
					</tr>
					<tr>
					  <td class="formbox-rowheader">站长名称:</td>
					  <td class="formbox-content"><input type="text" name="blogwebmaster" size="60" value="'.$settings['blogwebmaster'].'" maxlength="150" class="text" /></td>
					</tr>
					<tr>
					  <td class="formbox-rowheader">站长Email:</td>
					  <td class="formbox-content"><input type="text" name="masteremail" size="60" value="'.$settings['masteremail'].'" maxlength="150" class="text" /></td>
					</tr>
					<tr>
					  <td class="formbox-rowheader">网站友情连接:</td>
					  <td class="formbox-content"><textarea name="links" cols="64" wrap="virtual" rows="10" style="width:100%" > '.$settings['links'].'</textarea></td>
					</tr>
					
					<tr>
					  <td class="formbox-rowheader">语言代码:</td>
					  <td class="formbox-content"><input type="text" name="bloglanguage" size="20" value="'.$settings['bloglanguage'].'" maxlength="20" class="text" /> <span class="comment-text"><a href="http://blogs.law.harvard.edu/tech/stories/storyReader$15" target="_blank">* Language Code Reference for RSS</a></span></td>
					</tr>
					<tr>
					  <td class="formbox-rowheader">默认显示模式:</td>
					  <td class="formbox-content">'.$strviewmodel.'</td>
					</tr>
					<tr>
					  <td class="formbox-rowheader">每页日志数:</td>
					  <td class="formbox-content">普通: <input type="text" name="normalperpage" size="8" value="'.$settings['normalperpage'].'" maxlength="4" class="text" />&nbsp;&nbsp; 列表: <input type="text" name="listperpage" size="8" value="'.$settings['listperpage'].'" maxlength="4" class="text" /></td>
					</tr>
					<tr>
					  <td class="formbox-rowheader">每页评论数:</td>
					  <td class="formbox-content"><input type="text" name="percomment" size="4" value="'.$settings['percomment'].'" maxlength="4" class="text" />  记录
					  <span class="comment-text">(应用于日志显示页面. 设置为0则无限制.)</span></td>
					</tr>
					<tr>
					  <td class="formbox-rowheader">评论排序:</td>
					  <td class="formbox-content">'.$strcommentorder.'</td>
					</tr>
					<tr>
					  <td class="formbox-rowheader">最新日志数:</td>
					  <td class="formbox-content"><input type="text" name="newblognum" size="4" value="'.$settings['newblognum'].'" maxlength="4" class="text" />  记录</td>
					</tr>
					<tr>
					  <td class="formbox-rowheader">最新评论:</td>
					  <td class="formbox-content"><input type="text" name="newcomment" size="4" value="'.$settings['newcomment'].'" maxlength="4" class="text" />  记录</td>
					</tr>
					<tr>
					  <td class="formbox-rowheader">首页日志长度:</td>
					  <td class="formbox-content"><input type="text" name="indexbloglen" size="4" value="'.$settings['indexbloglen'].'" maxlength="4" class="text" /> 为0时不截取</td>
					</tr>
					<tr>
					  <td class="formbox-rowheader">开放注册:</td>
					  <td class="formbox-content">'.$strenablereg.'</td>
					</tr>
					<tr>
					  <td class="formbox-rowheader">使用校验码:</td>
					  <td class="formbox-content">'.$strsecuritycode.'</td>
					</tr>
					<tr>
					  <td class="formbox-rowheader">开放评论:</td>
					  <td class="formbox-content">'.$strenablecomment.'</td>
					</tr>
					<tr>
					  <td class="formbox-rowheader">评论最大长度:</td>
					  <td class="formbox-content"><input type="text" name="commentlen" size="4" value="'.$settings['commentlen'].'" maxlength="4" class="text" /> 字符数</td>
					</tr>
					<tr>
					  <td class="formbox-rowheader">开放留言:</td>
					  <td class="formbox-content">'.$strenablegb.'</td>
					</tr>
					<tr>
					  <td class="formbox-rowheader">每页留言数:</td>
					  <td class="formbox-content"><input type="text" name="guestbookperpage" size="4" value="'.$settings['guestbookperpage'].'" maxlength="4" class="text" /></td>
					</tr>
					<tr>
					  <td class="formbox-rowheader">网站样式选择:</td>
					  <td class="formbox-content">
					  <select name="style">
					  '.$stroption.'
					  </select>
					  </td>
					</tr>
					<tr>
					  <td class="formbox-rowheader">防灌机制:</td>
					  <td class="formbox-content"><input type="text" name="minposttime" size="4" value="'.$settings['minposttime'] .'" maxlength="4" class="text" /> 发帖间隔时间 <span class="comment-text">(对发表主题和评论均有效)</span></td>
					</tr>
					</tr>
					  <td class="formbox-rowheader">允许上传:</td>
					  <td class="formbox-content">
					  '.$strupload.'
					  </td>
					</tr>
					<tr>
					  <td class="formbox-rowheader">上传文件大小限制:</td>
					  <td class="formbox-content"><input type="text" name="uploadsize" size="8" value="'.$settings['uploadsize'].'" maxlength="20" class="text" /> Bytes</td>
					</tr>
					<tr>
					  <td class="formbox-rowheader">上传文件路径:</td>
					  <td class="formbox-content"><input type="text" name="uploadpath" size="60" value="'.$settings['uploadpath'].'" maxlength="250" class="text" /></td>
					</tr>
					<tr>
					  <td class="formbox-rowheader">上传文件类型:</td>
					  <td class="formbox-content"><input type="text" name="uploadtypes" size="60" value="'.$settings['uploadtypes'].'" maxlength="250" class="text" /> <span class="comment-text">(用 ,分开不区分大小写)</span></td>
					</tr>
					<tr>
					  <td></td>
					  <td><br /><input type="Submit" name="Submit" value=" 保存修改 " class="button" /></td>
					</tr>
					</form>
					</table>
					</div>';
		return $strHTML;
	}
	/**
	 * 保存基本设置
	 *
	 * @param array $settings 基本信息数组
	 */
	function saveSettings($settings)
	{
		global $cachepath;
		//Blog 主题
		SP('blogtitle',$settings['blogtitle'],'Blog 主题');
		//Blog 描述
		SP('blogmemo',$settings['blogmemo'],'Blog 描述');
		//Blog 链接
		SP('blogurl',$settings['blogurl'],'Blog 链接');
		//Blog Logo 图片
		SP('bloglogo',$settings['bloglogo'],'Blog Logo 图片');
		//站长名称:
		SP('blogwebmaster',$settings['blogwebmaster'],'站长名称');
		//站长Email
		SP('masteremail',$settings['masteremail'],'站长Email');
		//网站友情连接
		SP('links',$settings['links'],'网站友情连接');
		//语言
		SP('bloglanguage',$settings['bloglanguage'],'语言');
		//默认显示模式
		SP('viewmodel',$settings['viewmodel'],'默认显示模式');
		//每页日志数 普通/列表
		SP('normalperpage',$settings['normalperpage'],'每页日志数-普通');
		SP('listperpage',$settings['listperpage'],'每页日志数-列表');
		//每页评论数
		SP('percomment',$settings['percomment'],'每页评论数');
		//评论排序
		SP('commentorder',$settings['commentorder'],'评论排序');
		//最新日志
		SP('newblognum',$settings['newblognum'],'最新日志');
		//最新评论
		SP('newcomment',$settings['newcomment'],'最新评论');
		//首页日志显示长度，超长自动截断
		SP('indexbloglen',$settings['indexbloglen'],'首页日志显示长度，超过自动截取，为0时显示全部');
		//开放注册
		SP('enableregister',$settings['enableregister'],'是否开放注册');
		//使用校验码
		SP('enablesecuritycode',$settings['enablesecuritycode'],'是否使用校验码');
		//开放评论
		SP('enablecomment',$settings['enablecomment'],'是否开放评论');
		//评论最大长度
		SP('commentlen',$settings['commentlen'],'评论最大长度');
		//开放留言
		SP('enableguestbook',$settings['enableguestbook'],'开放留言');
		//每页留言数
		SP('guestbookperpage',$settings['guestbookperpage'],'每页留言数');
		//网站样式选择
		SP('style',$settings['style'],'网站样式选择');
		//防灌机制
		SP('minposttime',$settings['minposttime'],'防灌机制');
		//允许上传
		SP('enableupload',$settings['enableupload'],'是否允许上传');
		//上传文件大小限制
		SP('uploadsize',$settings['uploadsize'],'上传文件大小限制');
		//上传文件路径
		SP('uploadpath',$settings['uploadpath'],'上传文件路径');
		//上传文件类型
		SP('uploadtypes',$settings['uploadtypes'],'上传文件类型');
		//throw new Exception(implode('-',$settings));
		//清除缓存
		if (file_exists(ROOT_PATH.'./'.$cachepath.'config/webconfig.php')) {
			unlink(ROOT_PATH.'./'.$cachepath.'config/webconfig.php');
		}
	}
	/**
	 * 取指定分类信息
	 *
	 * @param int $cid 分类编号
	 * @return array 保存指定分类信息的数组
	 */
	function getCategoryInfo($cid)
	{
		global $db,$tablepre;
		$sql = 'select * from '.$tablepre.'categories where id='.$cid;
		$res = $db->query($sql);
		$cinfo = $db->db_fetch_array();
		return $cinfo;
	}
	/**
	 * 取得分类管理内的页面
	 *
	 * @return string 分类管理页面的HTML代码
	 */
	function getCategoriesPage()
	{
		global $db,$tablepre;
		$sql = 'select * from '.$tablepre.'categories order by indexs';
		$res = $db->query($sql);
		while ($arr = $db->db_fetch_array()) {
			if ($arr['hidden']==1) {
				$strhidden = 'checked="checked"';
			}else {
				$strhidden = '';
			}
			if ($arr['locked']==1) {
				$strlocked = 'checked="checked"';
			}else {
				$strlocked = '';
			}
			$arr['indexs'] = empty($arr['indexs'])?0:$arr['indexs'];
			$strcate .= '<tr>
					      <td><input type="checkbox" name="selected[]" value="'.$arr['id'].'" /><input type="hidden" name="id[]" value="'.$arr['id'].'" /></td>
					      <td><input type="text" name="name['.$arr['id'].']" size="30" maxlength="50" value="'.$arr['name'].'" class="text" /></td>
					      <td><input type="checkbox" name="hidden['.$arr['id'].']" value="1" '.$strhidden.' /></td>
					      <td><input type="checkbox" name="locked['.$arr['id'].']" value="1" '.$strlocked.' /></td>
					      <td><input type="text" name="order['.$arr['id'].']" size="2" maxlength="2" value="'.$arr['indexs'].'" class="text" /></td>
					      <td class="listbox-entry">'.$arr['articlenum'].'</td>
				      </tr>
				    ';
		}
		$strnew = '<tr>
					<td>新建:</td>
					<td><input type="text" name="new" size="30" maxlength="50" value="" class="text" /></td>
					<td><input type="checkbox" name="ishidden" value="1"  /></td>
			      	<td><input type="checkbox" name="islocked" value="1"  /></td>
			      	<td><input type="text" name="indexs" size="2" maxlength="2" value="" class="text" /></td>
			      	<td class="listbox-entry"></td>
				   </tr>';
		$strHTML = '<div class="textbox-title"><h4>分类</h4></div>
				  <div class="textbox-content">
				  <table border="0" cellpadding="3" cellspacing="2">
				    <form method="post" action="javascript:void(null);" id="cateform" onsubmit="return saveCategories();">
				    <tr>
				      <td class="listbox-header"></td>
				      <td class="listbox-header">标题</td>
				      <td class="listbox-header">隐藏</td>
				      <td class="listbox-header">锁定</td>
				      <td class="listbox-header">顺序</td>
				      <td class="listbox-header">日志</td>
				    </tr>
				  	'.$strcate.$strnew.'
				    <tr>
				      <td colspan="6">
				        <br />
				      	<select name="action">
									<option value="update">保存修改</option>
									<option value="move">移动日志到选定的分类</option>
									<option value="delete">删除选定的分类</option>
								</select>
				        <input type="submit" name="submit" value=" 执行 " class="button" />
				      </td>
				    </tr>
				    <tr>
				      <td colspan="6"><span class="red">* 删除分类将删除分类下的所有文章，评论，及引用.</span></td>
				    </tr>
				    </form>
				  </table>
				  </div>';
		return $strHTML;
	}
	/**
	 * 更新分类
	 *
	 * @param array $arrcontent 所有分类的内容
	 */
	function updateCategiries($arrcontent)
	{
		global $db,$tablepre;
		if (!is_array($arrcontent)) {
			throw new Exception('无效的更新信息');
		}
		foreach ($arrcontent as $key=>$fields){
			$strupdate .= ' `name`=\''.$fields['name'].'\',';
			$strupdate .= '`hidden`=\''.$fields['hidden'].'\',';
			$strupdate .= '`locked`=\''.$fields['locked'].'\',';
			$strupdate .= '`indexs`=\''.$fields['indexs'].'\'';
			$strupdate = 'update '.$tablepre.'categories set '.$strupdate.' where `id`='.$key;
			$db->query($strupdate);
			$strupdate = "";
		}
	}
	/**
	 * 添加新分类
	 *
	 * @param array $category 保存新分类数组
	 */
	function addCategory($category)
	{
		global $db,$tablepre;
		$sql = 'insert into '.$tablepre.'categories(`name`,`indexs`,`hidden`,`locked`) values(
				\''.$category['name'].'\',\''.$category['indexs'].'\',\''.$category['hidden'].'\',\''.$category['locked'].'\')';
		$db->query($sql);
	}
	/**
	 * 批量取得除指定分类ID外的所有其它分类列表
	 *
	 * @param array $cid 要排除的分类编号数组
	 * @return array 保存结果分类的数组
	 */
	function getOtherCategory($arrid)
	{
		global $db,$tablepre;
		$strid = implode(',',$arrid);
		$sql = 'select `id`,`name`,`articlenum` from '.$tablepre.'categories where id not in('.$strid.')';
		$db->query($sql);
		while ($arr = $db->db_fetch_array()) {
			$array[] = $arr;
		}
		return $array;
	}
	/**
	 * 批量获取分类信息
	 *
	 * @param array $arrid 要获取的分类编号数组
	 * @return array 得到的分类的二维数组
	 */
	function getCategories($arrid)
	{
		global $db,$tablepre;
		if (!is_array($arrid)||empty($arrid)) {
			throw new Exception('Error:category id error.');
		}
		$ids = implode(',',$arrid);
		$sql = 'select `id`,`name`,`articlenum` from '.$tablepre.'categories where id in('.$ids.')';
		$db->query($sql);
		while ($arr = $db->db_fetch_array()) {
			$array[] = $arr;
		}
		return $array;
	}
	
	/**
	 * 移动到另一分类的第二个页面
	 *
	 * @param array $arrfrom 要移动的分类列表
	 * @param array $arrcategory 移动到的列表
	 * @return string 页面的HTML代码
	 */
	function getMovetoHtml($arrfrom,$arrcategory)
	{
		if (!is_array($arrcategory)) {
			throw new Exception('Error:To category list error,the brand categories id is not array');
		}
		foreach ($arrcategory as $category){
			$str .='<option value="'.$category['id'].'">'.$category['name'].' ['.$category['articlenum'].']</option>'; 
		}
		foreach ($arrfrom as $froms){
			$namestr .= '['.$froms['name'].']';
			$tohtmlobj .= '<input type="hidden" name="selected[]" value="'.$froms['id'].'" />';
		}
		$strHTML = '
			<div class="formbox" style="width: 400px;">
			  <div class="formbox-title">选择目标分类</div>
			  <div class="formbox-content" style="padding: 10px;">
			    <center>
			    <table cellpadding="2" cellspacing="1">
			    <form method="post" action="javascript:void(null);" id="cateform" onsubmit="return saveCategories();">
			    <tr>
			      <td class="formbox-rowheader">从分类:</td>
			      <td class="formbox-content">
			      
			          '.$namestr.' 
			        
			      </td>
			    </tr>
			    <tr>
			      <td class="formbox-rowheader">到分类:</td>
			      <td class="formbox-content">	
			      	<select name="moveto">		
						'.$str.'
					</select>
			      </td>
			    </tr>
			    <tr>
			      <td></td>
			      <td class="formbox-content">
			        <br />
			        '.$tohtmlobj.'
			        <input type="hidden" name="action" value="savemoveto"/>
			        <input type="submit" name="submit" value=" 移动 " class="button" />
			        <input type="button" name="back" value=" 取消 " onClick="loadCategories();" class="button" />
			      </td>
			    </tr>
			    </form>
			    </table>
			    </center>
			  </div>
			  </tr>
			</div>';
		return $strHTML;
	}
	/**
	 * 移动到另一分类保存操作
	 *
	 * @param array $froms 起点数组
	 * @param array $tos 移动到的分类编号
	 */
	function saveMoveTo($froms,$toid)
	{
		global $db,$tablepre;
		//取得并验证原移动的分类信息
		foreach ($froms as $fromid){
			$fromid = is_numeric($fromid)?$fromid:0;
			if (!$fromid) {
				throw new Exception('Error:From id is error');
			}
			$frominfo = $this->getCategoryInfo($fromid);
			if (!is_array($frominfo)) {
				throw new Exception('Error:错误的从分类：'.$fromid);
			}
			$oldnum = $oldnum + $frominfo['articlenum'];
		}
		$toinfo = $this->getCategoryInfo($toid);
		if (!is_array($toinfo)) {
				throw new Exception('Error:错误的目标分类：'.$fromid);
		}
		$fromidstr = implode(',',$froms);
		//更新文章所属分类，原分类的文章数量(0)，移动后的分类的文章数量
		$sql = 'update '.$tablepre.'articles set category = '.$toid.' where category in ('.$fromidstr.')';
		$db->query($sql);
		$sql = 'update '.$tablepre.'categories set articlenum = articlenum +'.$oldnum.' where id='.$toid;
		$db->query($sql);
		$sql = 'update '.$tablepre.'categories set articlenum = 0 where id in ('.$fromidstr.')';
		$db->query($sql);
	}
	/**
	 * 删除分类
	 *
	 */
	function delCategory($cid)
	{
		global $db,$tablepre;
		$sql = 'delete from '.$tablepre.'categories where id='.$cid;
		$db->query($sql);
		$sql = 'delete from '.$tablepre.'articles where category ='.$cid;
		$db->query($sql);
	}
	/**
	 * 取得所有用户组的信息
	 *
	 * @return 保存用户组的数组
	 */
	function getUserGroups()
	{
		global $db,$tablepre;
		$sql = 'select * from '.$tablepre.'usergroup';
		$res = $db->query($sql);
		while ($arr = $db->db_fetch_array($res)) {
			$array[] = $arr;
		}
		return $array;
	}
	/**
	 * 查找指定的用户组编号取用户组信息
	 *
	 * @param int $id 用户组编号
	 * @return array 用户组信息
	 */
	function getUserGroupById($id)
	{
		global $db,$tablepre;
		$id = is_numeric($id)?$id:0;
		if ($id==0) {
			throw new Exception('Error:错误的用户组编号');
		}
		$sql = 'select * from '.$tablepre.'usergroup where id='.$id;
		$res = $db->query($sql);
		$array = $db->db_fetch_array();
		return $array;
	}
	/**
	 * 用户组页面的HTML代码
	 *
	 * @param array $UserGroups 用户组信息
	 * @return string 页面HTML代码
	 */
	function getUserGroupPage($UserGroups)
	{
		if (is_array($UserGroups)) {
			foreach ($UserGroups as $UserGroup){
				$right = $UserGroup['rights'];
				$viewRight = empty($right[0])?0:intval($right[0]);
				$postRight = empty($right[1])?0:intval($right[1]);
				$editRight = empty($right[2])?0:intval($right[2]);
				$delRight = empty($right[3])?0:intval($right[3]);
				$uploadRight = empty($right[4])?0:intval($right[4]);
				$viewStr = '
				<select name="view[]">
				<option value="0" '.($viewRight==0?'selected="selected"':'').'>无</option>
				<option value="1" '.($viewRight==1?'selected="selected"':'').'>普通</option>
				<option value="2" '.($viewRight==2?'selected="selected"':'').'>隐藏</option>
				<option value="3" '.($viewRight==3?'selected="selected"':'').'>私人</option>
				</select>';
				$postStr = '
				<select name="post[]">
				<option value="0" '.($postRight==0?'selected="selected"':'').'>无</option>
				<option value="1" '.($postRight==1?'selected="selected"':'').'>评论</option>
				<option value="2" '.($postRight==2?'selected="selected"':'').'>日志和评论</option>
				</select>';
				$editStr = '
				<select name="edit[]">
				<option value="0" '.($editRight==0?'selected="selected"':'').'>无</option>
				<option value="1" '.($editRight==1?'selected="selected"':'').'>私有</option>
				<option value="2" '.($editRight==2?'selected="selected"':'').'>全部</option>
				</select>';
				$delStr = '
				<select name="delete[]">
				<option value="0" '.($delRight==0?'selected="selected"':'').'>无</option>
				<option value="1" '.($delRight==1?'selected="selected"':'').'>私有</option>
				<option value="2" '.($delRight==2?'selected="selected"':'').'>全部</option>
				</select>';
				$uploadStr = '
				<select name="upload[]">
				<option value="0" '.($uploadRight==0?'selected="selected"':'').'>禁用</option>
				<option value="1" '.($uploadRight==1?'selected="selected"':'').'>可用</option>
				</select>';
				$strRow .= '
				<tr>
					<td>
					<input type="checkbox" '.($UserGroup['grouptype']==0?'name="not_for_select" disabled="disabled"':('name="selected[]" value="'.$UserGroup['id'].'"')).'" />
					<input type="hidden" name="id[]" value="'.$UserGroup['id'].'" />
					<input type="hidden" name="grouptype[]" value="'.$UserGroup['grouptype'].'" />
					</td>
					<td>
					<input type="text" name="name[]" size="10" maxlength="50" value="'.$UserGroup['groupname'].'" class="text" />
					</td>
					<td>'.$viewStr.'
					</td>
					<td>'.$postStr.'
					</td>
					<td>'.$editStr.'
					</td>
					<td>'.$delStr.'
					</td>
					<td>'.$uploadStr.'
					</td>
				</tr>';
			}
		}else {
			$strRow = '';
		}
		//throw new Exception($strRow);
		$strHTML ='
		<div class="textbox">
		<div class="textbox-title"><h4>用户群组</h4></div>
			<div class="textbox-content">
			<table border="0" cellpadding="3" cellspacing="2">
			<form method="post" id="usergroupform" action="javascript:void(null);" onsubmit="return saveUserGroup();">
				<tr>
					<td class="listbox-header"></td>
					<td class="listbox-header"></td>
					<td class="listbox-header">浏览</td>
					<td class="listbox-header">发表</td>
					<td class="listbox-header">编辑</td>
					<td class="listbox-header">删除</td>
					<td class="listbox-header">上传</td>
				</tr>
				'.$strRow.'
				<tr>
					<td>新建:</td>
					<td><input type="hidden" name="id[]" value="0" /> <input type="text" name="name[]" size="10" maxlength="50" value="" class="text" /></td>
					<td>
					<select name="view[]">
					<option value="0">无</option>
					<option value="1">普通</option>
					<option value="2">隐藏</option>
					<option value="3">私人</option>
					</select>
					</td>
					<td>
					<select name="post[]">
					<option value="0">无</option>
					<option value="1">评论</option>
					<option value="2">日志</option>
					</select>
					</td>
					<td>
					<select name="edit[]">
					<option value="0">无</option>
					<option value="1">私有</option>
					<option value="2">全部</option>
					</select>
					</td>
					<td>
					<select name="delete[]">
					<option value="0">无</option>
					<option value="1">私有</option>
					<option value="2">全部</option>
					</select>
					<td>
					<select name="upload[]">
					<option value="0">禁用</option>
					<option value="1">可用</option>
					</select>
					</td>
				</tr>
				<tr>
					<td colspan="6">
					<br />
					<select name="action">
					<option value="update">保存修改</option>
					<option value="delete">删除用户组</option>
					</select>
					<input type="submit" name="submit" value=" 执行 " class="button" />
					</td>
				</tr>
				<tr>
					<td colspan="6"><span class="red">* 删除用户组将删除该组内所有用户</span></td>
				</tr>
			</form>
			</table>
			</div>
		</div>';
		return $strHTML;
	}
	/**
	 * 保存和添加用户组
	 *
	 * @param unknown_type $arrUserGroups
	 */
	function saveUserGroup($arrUserGroups)
	{
		global $db,$tablepre;
		$now = time();
		if (is_array($arrUserGroups['id'])) {
			foreach ($arrUserGroups['id'] as $key=>$userGroupId){
				$userGroupId = is_numeric($userGroupId)?$userGroupId:0;
				$rightStr = intval($arrUserGroups['view'][$key]).intval($arrUserGroups['post'][$key]).intval($arrUserGroups['edit'][$key]).intval($arrUserGroups['delete'][$key]).intval($arrUserGroups['upload'][$key]);
				$groupName = addslashes($arrUserGroups['name'][$key]);
				$groupType = $arrUserGroups['grouptype'][$key]=='1'?1:0;
				if ($userGroupId==0) {
					//添加新的
					if ($groupName!='') {
						$strInsert = 'insert into '.$tablepre.'usergroup(`groupname`,`rights`,`grouptype`,`adddate`) values(\''.$groupName.'\','.$rightStr.',1,\''.$now.'\')';
						$db->query($strInsert);
					}
					continue;
				}
				$strUpdate = 'update '.$tablepre.'usergroup set `groupname`=\''.$groupName.'\',`grouptype`=\''.$groupType.'\',`rights`=\''.$rightStr.'\' where `id`='.$userGroupId;
				$db->query($strUpdate);
			}
		}else {
			throw new Exception('Error:没有信息要编辑');
		}
	}
	/**
	 * 删除用户组
	 *
	 * @param array $arrUserGroups 要删除的用户组信息 一定要有"selected" 对像，保存着要删除的ID
	 */
	function deleteUserGroup($arrUserGroups)
	{
		global $db,$tablepre;
		if (is_array($arrUserGroups['selected'])) {
			foreach ($arrUserGroups['selected'] as $groupId){
				$groupId = is_numeric($groupId)?$groupId:0;
				if ($groupId ==0) {
					continue;
				}
				$arrGroupInfo = $this->getUserGroupById($groupId);
				if ($arrGroupInfo['grouptype']==0) {
					throw new Exception('Error:系统类型编号用户组不能删除');
				}
				$sql_deluser = 'delete from '.$tablepre.'users where groupid ='.$groupId;
				$db->query($sql_deluser);
				$sql_delgroup = 'delete from '.$tablepre.'usergroup where id ='.$groupId;
				$db->query($sql_delgroup);
			}
		}else {
			throw new Exception('Error:请先择要删除的用户组');
		}
	}
	/**
	 * 取得所有系统表情
	 *
	 * @return 表情数组
	 */
	function getSmilies()
	{
		global $db,$tablepre;
		$sql = 'select * from '.$tablepre.'smilies';
		$res = $db->query($sql);
		while ($arr = $db->db_fetch_array($res)) {
			$array[] = $arr;
		}
		return $array;
	}
	/**
	 * 表情编辑页面
	 *
	 * @param array $arrSmilies 所有表情数组
	 * @return  string 表情页的HTML代码
	 */
	function getSmiliesPage($arrSmilies)
	{
		global $smilepath;
		if (is_array($arrSmilies)) {
			foreach ($arrSmilies as $smilies){
				$strRow .= '
				<tr>
					<td><input type="checkbox" name="selected[]" value="'.$smilies['id'].'" /><input type="hidden" name="id[]" value="'.$smilies['id'].'" /></td>
					<td><img src="'.$smilepath.$smilies['picname'].'" /></td>
					<td><input type="text" name="code[]" size="10" maxlength="50" value="'.$smilies['code'].'" class="text" /></td>
					<td><input type="text" name="image[]" size="30" maxlength="50" value="'.$smilies['picname'].'" class="text" /></td>
				</tr>';
			}
		}else{
			$strRow = '';
		}
		$strHTML = '
			<div class="textbox">
				<div class="textbox-title"><h4>表情图标</h4></div>
				<div class="textbox-content">
					<table border="0" cellpadding="3" cellspacing="2">
				    <form method="post" id="smiliesform" action="javascript:void(null);" onsubmit="return saveSmilies();">
				    <tr>
				      <td class="listbox-header"></td>
				      <td class="listbox-header">图片</td>
				      <td class="listbox-header">代码</td>
				      <td class="listbox-header">链接</td>
				    </tr>
				    '.$strRow.'
				    <tr>
				      <td>新建:<input type="hidden" name="id[]" value="0" /></td>
				      <td><img src="styles/default/images/blank.gif" id="imgPreview" /></td>
				      <td><input type="text" name="code[]" size="10" maxlength="50" value="" class="text" /></td>
				      <td><input type="text" name="image[]" size="30" maxlength="50" value="" class="text" onKeyUp="if(this.value.length>0){imgPreview.src=\''.$smilepath.'\'+this.value;}else{imgPreview.src=\'styles/default/images/blank.gif\';}" /></td>
				    </tr>
				    <tr>
				      <td colspan="5">
				        <br />
				      	<select name="action">
							<option value="update">保存修改</option>
							<option value="delete">删除选定的表情</option>
						</select>
				        <input type="submit" name="submit" value=" 执行 " class="button" />
				      </td>
				    </tr>
				    </form>
				  </table>
				</div>
			</div>';
		return $strHTML;
	}
	/**
	 * 保存和添加表情
	 *
	 * @param array $arrSmilies 表情表单数组
	 */
	function saveSmilies($arrSmilies)
	{
		global $db,$tablepre;
		if (is_array($arrSmilies['id'])) {
			foreach ($arrSmilies['id'] as $key=>$smiliesId){
				$smiliesId = is_numeric($smiliesId)?$smiliesId:0;
				$picName = addslashes($arrSmilies['image'][$key]);
				$code = addslashes($arrSmilies['code'][$key]);
				if ($smiliesId==0) {
					//添加新的
					if ($picName!='' && $code!='') {
						$strInsert = 'insert into '.$tablepre.'smilies(`picname`,`code`) values(\''.$picName.'\',\''.$code.'\')';
						$db->query($strInsert);
					}
					continue;
				}
				$strUpdate = 'update '.$tablepre.'smilies set `picname`=\''.$picName.'\',`code`=\''.$code.'\' where `id`='.$smiliesId;
				$db->query($strUpdate);
			}
		}else {
			throw new Exception('Error:没有信息要编辑');
		}
	}
	/**
	 * 删除表情
	 *
	 * @param array $arrsmilies 要删除的表情信息 一定要有"selected" 对像，保存着要删除的ID
	 */
	function deleteSmilies($arrSmilies)
	{
		global $db,$tablepre;
		if (is_array($arrSmilies['selected'])) {
			foreach ($arrSmilies['selected'] as $smiliesId){
				$smiliesId = is_numeric($smiliesId)?$smiliesId:0;
				if ($smiliesId ==0) {
					continue;
				}
				$sql_del = 'delete from '.$tablepre.'smilies where id ='.$smiliesId;
				$db->query($sql_del);
			}
		}else {
			throw new Exception('Error:请先择要删除的表情组');
		}
	}
	/**
	 * 取得所有过虑表
	 *
	 * @return 过虑表数组
	 */
	function getWordFilter()
	{
		global $db,$tablepre;
		$sql = 'select * from '.$tablepre.'wordfilter';
		$res = $db->query($sql);
		while ($arr = $db->db_fetch_array($res)) {
			$array[] = $arr;
		}
		return $array;
	}
	/**
	 * 字符过虑修改页面
	 *
	 * @param array $arrSmilies 所有表情数组
	 * @return  string 字符过虑页的HTML代码
	 */
	function getWordFilterPage($arrWordFilter)
	{
		if (is_array($arrWordFilter)) {
			foreach ($arrWordFilter as $wordFilter){
				$strRow .= '
				<tr>
					<td><input type="checkbox" name="selected[]" value="'.$wordFilter['id'].'" /><input type="hidden" name="id[]" value="'.$wordFilter['id'].'" /></td>
					<td><input type="text" name="oldvalue[]" size="20" maxlength="50" value="'.$wordFilter['oldvalue'].'" class="text" /></td>
					<td><input type="text" name="newvalue[]" size="20" maxlength="50" value="'.$wordFilter['newvalue'].'" class="text" /></td>
				</tr>';
			}
		}else{
			$strRow = '';
		}
		$strHTML = '
			<div class="textbox">
				<div class="textbox-title"><h4>字符过虑</h4></div>
				<div class="textbox-content">
					<table border="0" cellpadding="3" cellspacing="2">
				    <form method="post" id="wordfilterform" action="javascript:void(null);" onsubmit="return saveWordFilter();">
				    <tr>
				      <td class="listbox-header"></td>
				      <td class="listbox-header">原字符</td>
				      <td class="listbox-header">新字符</td>
				    </tr>
				    '.$strRow.'
				    <tr>
				      <td>新建:<input type="hidden" name="id[]" value="0" /></td>
				      <td><input type="text" name="oldvalue[]" size="10" maxlength="50" value="" class="text" /></td>
				      <td><input type="text" name="newvalue[]" size="30" maxlength="50" value="" class="text" /></td>
				    </tr>
				    <tr>
				      <td colspan="5">
				        <br />
				      	<select name="action">
							<option value="update">保存修改</option>
							<option value="delete">删除选定的过虑器</option>
						</select>
				        <input type="submit" name="submit" value=" 执行 " class="button" />
				      </td>
				    </tr>
				    </form>
				  </table>
				</div>
			</div>';
		return $strHTML;
	}
	/**
	 * 保存和添加过虑器
	 *
	 * @param array $arrWordFilter 过虑器表单数组
	 */
	function saveWordFilter($arrWordFilter)
	{
		global $db,$tablepre;
		$now = time();
		if (is_array($arrWordFilter['id'])) {
			foreach ($arrWordFilter['id'] as $key=>$wordFilterId){
				$wordFilterId = is_numeric($wordFilterId)?$wordFilterId:0;
				$oldValue = addslashes($arrWordFilter['oldvalue'][$key]);
				$newValue = addslashes($arrWordFilter['newvalue'][$key]);
				if ($wordFilterId==0) {
					//添加新的
					if ($oldValue!='') {
						$strInsert = 'insert into '.$tablepre.'wordfilter(`oldvalue`,`newvalue`) values(\''.$oldValue.'\',\''.$newValue.'\')';
						$db->query($strInsert);
					}
					continue;
				}
				$strUpdate = 'update '.$tablepre.'wordfilter set `oldvalue`=\''.$oldValue.'\',`newvalue`=\''.$newValue.'\' where `id`='.$wordFilterId;
				$db->query($strUpdate);
			}
		}else {
			throw new Exception('Error:没有信息要编辑');
		}
	}
	/**
	 * 删除表情
	 *
	 * @param array $arrsmilies 要删除的表情信息 一定要有"selected" 对像，保存着要删除的ID
	 */
	function deleteWordFilter($arrWordFilter)
	{
		global $db,$tablepre;
		if (is_array($arrWordFilter['selected'])) {
			foreach ($arrWordFilter['selected'] as $wordFilterId){
				$wordFilterId = is_numeric($wordFilterId)?$wordFilterId:0;
				if ($wordFilterId ==0) {
					continue;
				}
				$sql_del = 'delete from '.$tablepre.'wordfilter where id ='.$wordFilterId;
				$db->query($sql_del);
			}
		}else {
			throw new Exception('Error:请先择要删除的表情组');
		}
	}
	/**
	 * 显示公告页内容
	 *
	 * @return 公告页HTML代码
	 */
	function getAnnouncePage()
	{
		global $virdir;
		$announce = GP('announce');
		$showannounce = GP('showannounce');
		if ($showannounce=='1') {
			$strshow = '<input type="checkbox" name="show" value="1" checked="checked" />';
		}else {
			$strshow = '<input type="checkbox" name="show" value="1" />';
		}
		$strHTML = '
		<div class="textbox">
		  <div class="textbox-title"><h4>公告</h4></div>
		  <div style="width: 100%">
		  <table border="0" cellpadding="3" cellspacing="2" width="100%">
		    <form name="inputform" id="announceform" method="post" action="javascript:void(null);" onsubmit="saveAnnounce();">
		    <tr>
		      <td class="formbox-rowheader" width="150">可用:</td>
		      <td class="formbox-content">'.$strshow.'显示公告</td>
		    </tr>
		    <tr>
		      <td class="formbox-rowheader">
		        <div class="panel-smilies">
		          <div class="panel-smilies-title">表情图标</div>
		          <div class="panel-smilies-content">
		          
		            <a href="javascript:insertSmilies(\'[smile]\')"><img src="styles/default/images/smilies/icon_smile.gif" alt="[smile]" /></a>
		            
		            <a href="javascript:insertSmilies(\'[confused]\')"><img src="styles/default/images/smilies/icon_confused.gif" alt="[confused]" /></a>
		            
		            <a href="javascript:insertSmilies(\'[cool]\')"><img src="styles/default/images/smilies/icon_cool.gif" alt="[cool]" /></a>
		            
		            <a href="javascript:insertSmilies(\'[cry]\')"><img src="styles/default/images/smilies/icon_cry.gif" alt="[cry]" /></a>
		            <br />
		
		            <a href="javascript:insertSmilies(\'[eek]\')"><img src="styles/default/images/smilies/icon_eek.gif" alt="[eek]" /></a>
		            
		            <a href="javascript:insertSmilies(\'[angry]\')"><img src="styles/default/images/smilies/icon_angry.gif" alt="[angry]" /></a>
		            
		            <a href="javascript:insertSmilies(\'[wink]\')"><img src="styles/default/images/smilies/icon_wink.gif" alt="[wink]" /></a>
		            
		            <a href="javascript:insertSmilies(\'[sweat]\')"><img src="styles/default/images/smilies/icon_sweat.gif" alt="[sweat]" /></a>
		            <br />
		
		            <a href="javascript:insertSmilies(\'[lol]\')"><img src="styles/default/images/smilies/icon_lol.gif" alt="[lol]" /></a>
		            
		            <a href="javascript:insertSmilies(\'[stun]\')"><img src="styles/default/images/smilies/icon_stun.gif" alt="[stun]" /></a>
		            
		            <a href="javascript:insertSmilies(\'[razz]\')"><img src="styles/default/images/smilies/icon_razz.gif" alt="[razz]" /></a>
		            
		            <a href="javascript:insertSmilies(\'[redface]\')"><img src="styles/default/images/smilies/icon_redface.gif" alt="[redface]" /></a>
		            <br />
		
		            <a href="javascript:insertSmilies(\'[rolleyes]\')"><img src="styles/default/images/smilies/icon_rolleyes.gif" alt="[rolleyes]" /></a>
            
		            <a href="javascript:insertSmilies(\'[sad]\')"><img src="styles/default/images/smilies/icon_sad.gif" alt="[sad]" /></a>
		            
		            <a href="javascript:insertSmilies(\'[yes]\')"><img src="styles/default/images/smilies/icon_yes.gif" alt="[yes]" /></a>
		            
		            <a href="javascript:insertSmilies(\'[no]\')"><img src="styles/default/images/smilies/icon_no.gif" alt="[no]" /></a>
		            <br />
		
		            <a href="javascript:insertSmilies(\'[heart]\')"><img src="styles/default/images/smilies/icon_heart.gif" alt="[heart]" /></a>
		            
		            <a href="javascript:insertSmilies(\'[star]\')"><img src="styles/default/images/smilies/icon_star.gif" alt="[star]" /></a>
		            
		            <a href="javascript:insertSmilies(\'[music]\')"><img src="styles/default/images/smilies/icon_music.gif" alt="[music]" /></a>
		            
		            <a href="javascript:insertSmilies(\'[idea]\')"><img src="styles/default/images/smilies/icon_idea.gif" alt="[idea]" /></a>
		            <br />
		
		          </div>
		          <div style="font-weight: normal; text-align:left;">
								<input name="e_html" type="checkbox" value="true" /> 使用HTML<br />
								<input name="e_ubb" type="checkbox" value="true" checked />  UBB代码<br />
								<input name="e_autourl" type="checkbox" value="true" checked /> 转换链接<br />
								<input name="e_image" type="checkbox" value="true" checked /> 显示图片<br />
								<input name="e_media" type="checkbox" value="true" checked /> 显示媒体<br />
								<input name="e_smilies" type="checkbox" value="true" checked /> 表情图标
				  </div>
		      </td>
		      <td class="formbox-content">
		        <textarea name="message" cols="64" rows="16" wrap="virtual" id="message" style="width:100%" onSelect="storeCaret(this);" onClick="storeCaret(this);" onKeyup="storeCaret(this);CtrlEnter();">'.$announce.'</textarea>
		        <br />
		        <input type="submit" name="submit" value=" 保存修改 " class="button" />
		      </td>
		    </tr>
		    </form>
		  </table>
		  </div>
		</div>';
		return $strHTML;
	}
	/**
	 * 保存系统公告
	 *
	 * @param array $arrAnnounce 公告表单内容
	 */
	function saveAnnounce($arrAnnounce)
	{
		//global $db,$tablepre;
		$showAnnounce = $arrAnnounce['show']=='1'?1:0;
		$announce = $arrAnnounce['message'];
		SP('showannounce',$showAnnounce,'是否显示公告');
		SP('announce',$announce,'系统公告内容');
	}
}
?>